package de.jmda.mview.typeshape.relation;


/**
 * <b>R</b>elation <b>E</b>ndpoint <b>C</b>onnection (REC) connecting source
 * with target connector point in orthogonal routing style. Both relation
 * endpoints have vertical direction (V2V).
 *
 * @author roger.jmda@gmail.com
 */
public abstract class RECOV2V
    extends RECOrthogonal
{
	/**
	 * @param relationEndpointHelperSource
	 * @param relationEndpointHelperTarget
	 */
	public RECOV2V(
      RelationEndpointHelper relationEndpointHelperSource,
      RelationEndpointHelper relationEndpointHelperTarget)
			throws IllegalArgumentException
  {
	  super(relationEndpointHelperSource, relationEndpointHelperTarget);
  }
	
	@Override
	protected void checkStateInvalidated() throws StateInvalidatedException
	{
		super.checkStateInvalidated();

	  // check if both relation endpoints are vertical
	  if (false == checkRelationEndpointsVertical())
		{
			throw new StateInvalidatedException(
					"both relation endpoints have to be vertical\n" +
					"source relation endpoint is vertical: " +
							relationEndpointHelperSource.isVertical() + "\n" +
					"target relation endpoint is vertical: " +
							relationEndpointHelperTarget.isVertical());
		}
	}

	private boolean checkRelationEndpointsVertical()
	{
		return
				RECOV2V.checkRelationEndpointsVertical(
						relationEndpointHelperSource, relationEndpointHelperTarget);
	}
	
	public static boolean checkRelationEndpointsVertical(
			RelationEndpointHelper r1, RelationEndpointHelper r2)
	{
		return r1.isVertical() && r2.isVertical();
	}
}